<!--基本业务查询-大小额基本业务查询-->
<template>
  <div class="app-container">
    <ht-search-form
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :beforeSearchCallback="false"
      @beforeSearchCallback="beforeSearchCallback"
      :clearCallBack="clearCallBack"
    >
      <template slot="endSlotOption">
        <amount-range-search label="金额区间" ref="amountRangeSearch"></amount-range-search>
      </template>
    </ht-search-form>
    <ht-table
      ref="dataTable"
      rowKey="coreId"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="80" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    toViewDetail(scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <query-detail-111 ref="queryDetail111" :dictMap="dictMap"></query-detail-111>
    <query-detail-115 ref="queryDetail115" :dictMap="dictMap"></query-detail-115>
    <query-detail-112 ref="queryDetail112" :dictMap="dictMap"></query-detail-112>
    <query-detail-116 ref="queryDetail116" :dictMap="dictMap"></query-detail-116>
    <query-detail-117 ref="queryDetail117" :dictMap="dictMap"></query-detail-117>
    <query-detail-118 ref="queryDetail118" :dictMap="dictMap"></query-detail-118>
    <query-detail-121 ref="queryDetail121" :dictMap="dictMap"></query-detail-121>
    <query-detail-122 ref="queryDetail122" :dictMap="dictMap"></query-detail-122>
    <query-detail-127 ref="queryDetail127" :dictMap="dictMap"></query-detail-127>
    <query-detail-133 ref="queryDetail133" :dictMap="dictMap"></query-detail-133>
    <query-detail-125 ref="queryDetail125" :dictMap="dictMap"></query-detail-125>
    <query-detail-141001 ref="queryDetail141001" :dictMap="dictMap"></query-detail-141001>
    <query-detail-141002 ref="queryDetail141002" :dictMap="dictMap"></query-detail-141002>

  </div>
</template>
<script>
import { apiUrlConfig } from "@/api/cnaps/baseBiz/inquire/index";
import queryDetail111 from "@/views/cnaps/baseBiz/send/components/queryDetail111";
import queryDetail115 from "@/views/cnaps/baseBiz/send/hvps/hvps115/components/queryDetail115";
import queryDetail112 from "@/views/cnaps/baseBiz/send/components/queryDetail112";
import queryDetail116 from "@/views/cnaps/baseBiz/send/hvps/hvps116/components/queryDetail116";
import queryDetail117 from "@/views/cnaps/baseBiz/send/hvps/hvps117/components/queryDetail117";
import queryDetail118 from "@/views/cnaps/baseBiz/send/hvps/hvps118/components/queryDetail118";
import queryDetail121 from "@/views/cnaps/baseBiz/send/components/queryDetail121"
import queryDetail122 from "@/views/cnaps/baseBiz/send/components/queryDetail122"
import queryDetail127 from "@/views/cnaps/baseBiz/send/components/queryDetail127"
import queryDetail133 from "@/views/cnaps/baseBiz/send/components/queryDetail133"
import queryDetail125 from "@/views/cnaps/baseBiz/send/components/queryDetail125"
import queryDetail141001  from "@/views/cnaps/baseBiz/send/hvps/hvps141/components/queryDetail141001";
import queryDetail141002  from "@/views/cnaps/baseBiz/send/hvps/hvps141/components/queryDetail141002";



import { listPageMixin } from "@/libs/listPageMixin";
import AmountRangeSearch from "@/views/components/AmountSearchInput";
export default {
  name: "baseBizInqIndex",
  mixins: [listPageMixin],
  components: {
    AmountRangeSearch,
    queryDetail111,
    queryDetail115,
    queryDetail112,
    queryDetail116,
    queryDetail117,
    queryDetail118,
    queryDetail121,
    queryDetail122,
    queryDetail127,
    queryDetail133,
    queryDetail125,
    queryDetail141001,
    queryDetail141002,
  },
  data() {
    return {
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: [
        "PKG_TYPE_HVPSBEPS",
        "Cnaps2Dict.DRCTCODE",
        "Cnaps2Dict.SYS_CODE",
        "Cnaps2Dict.CP2_STATUS",
        "Cnaps2Dict.PROCESSSTATUS",
        "BIZ_TYPE_111",
        "BIZ_TYPE_112",
        "BIZ_TYPE_122",
        "BIZ_TYPE_121",
        "PRIORITY3CODE",
        "CUST_FLAG1",
        "TXN_STATUS",
        "PKG_STATUS",
        "PROCESSSTATUS",
        "CBFLAG",
        "NON_STP_TYPE",
        "TXN_SOURCE",
        "SYS_CODE",
        "NON_STP_TYPE",
        "BIZ_CTGY",
        "CP2_STATUS",
        "BUDGETLEVELCODE",
        "INDICATOR_CODE",
        "BUDGETTYPECODE",
        "BIZ_TYPE",
        "DRCTCODE",
        "CREDITDEBITCODE",
        "CUST_STATUS",
        "CBSTATUS",
        "Cnaps2Dict.CP2_BRNO",
        "BIZ_TYPE_116",
        "BIZ_CTGY_116",
        "BIZRT_STATUS"
      ],
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: "",
        cpgdate: "",
        cpgdate2: "",
        workdate: "",
        workdate2: "",
        drct: "",
        sysCode: "",
        procStatus: "",
        pkgNo: "",
        payerActno: "",
        payeeActno: "",
        amount1: "",
        amount2: "",
        source: "",
      },
      formOptions: [],
      tableBindColumns: [
        { label: `内部机构号`, prop: "brno", dictCode: "Cnaps2Dict.CP2_BRNO", width: "160" },
        { label: `系统编号`, prop: "sysCode", dictCode: "Cnaps2Dict.SYS_CODE", width: "160" },
        { label: `交易来源`, prop: "source", dictCode: "Cnaps2Dict.TXN_SOURCE", sortable: false },
        { label: `交易流水号`, prop: "coreId", width: "160" },
        { label: `CPG日期`, prop: "vdate" },
        { label: `工作日期`, prop: "workdate" },
        {
          label: `报文类型`,
          prop: "pkgNo",
          formatter: (row) => {
            if (!row.pkgNo) {
              return "-";
            }
            return `${row.pkgNo + "-" + row.pkgNoDesc}`;
          },
        },
        {
          label: `业务类型`,
          prop: "bizTypeCode",
          formatter: (row) => {
            if (!row.bizTypeCode) {
              return "-";
            }
            return `${row.bizTypeCode + "-" + row.bizTypeCodeDesc}`;
          },
          sortable: false,
          width: 200,
        },
        {
          label: `业务种类`,
          prop: "bizCtgyCode",
          formatter: (row) => {
            if (!row.bizCtgyCode) {
              return "-";
            }
            return `${row.bizCtgyCode + "-" + row.bizCtgyCodeDesc}`;
          },
          sortable: false,
          width: 200,
        },
        {
          label: `来往账标志`,
          prop: "drct",
          width: "100",
          dictCode: "Cnaps2Dict.DRCTCODE",
          sortable: false,
        },
        {
          label: `付款人账号`,
          prop: "payerActno",
          sortable: false,
        },
        {
          label: `付款人姓名`,
          prop: "payerName",
          width: "120",
        },
        {
          label: `付款银行名`,
          prop: "payerBrname",
          width: "120",
        },
        {
          label: `收款人账号`,
          prop: "payeeActno",
          width: "120",
        },
        {
          label: `收款人姓名`,
          prop: "payeeName",
          width: "120",
        },
        {
          label: `收款银行名`,
          prop: "payeeBrname",
          width: "120",
        },
        {
          label: `交易金额`,
          prop: "amount",
          type: "price",
          sortable: false,
        },
        {
          label: `业务状态`,
          prop: "status",
          sortable: false,
          width: "80",
          fixed: "right",
          dictCode: "Cnaps2Dict.CP2_STATUS",
        },
        {
          label: `通讯状态`,
          prop: "comStatus",
          width: "100",
          fixed: "right",
          dictCode: "Cnaps2Dict.COM_STATUS",
          sortable: false,
        },
        {
          label: `中心状态`,
          prop: "procStatus",
          width: "100",
          fixed: "right",
          dictCode: "Cnaps2Dict.PROCESSSTATUS",
          sortable: false,
        },
      ],
    };
  },
  mounted() {
    this.$refs.amountRangeSearch.$on('getAmountRange',this.beforeSearchCallback);
    this.formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          label: "流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "search-dept-tree",
        prop: "brno",
        defaultAttr: {
          radio: false,
          linkParentChoose: false,
          label: "分行选择",
          placeholder: "请选择分行",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate1",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate1",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          label: "工作日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dict",
        dict: "Cnaps2Dict.DRCTCODE",
        prop: "drct",
        defaultAttr: {
          label: "来往账标志",
          placeholder: "请选择来往账标志",
        },
      },
      {
        type: "dict",
        dict: "Cnaps2Dict.SYS_CODE",
        prop: "sysCode",
        defaultAttr: {
          label: "系统编号",
          placeholder: "请选择系统编号",
        },
      },
      {
        type: "dict",
        dict: "Cnaps2Dict.PROCESSSTATUS",
        prop: "procStatus",
        defaultAttr: {
          label: "中心状态",
          placeholder: "请选择中心状态",
        },
      },
      {
        type: "dict",
        dict: "PKG_TYPE_HVPSBEPS",
        prop: "pkgNo",
        defaultAttr: {
          label: "报文类型",
          placeholder: "请选择报文类型",
        },
      },
      {
        type: "input",
        prop: "payerActno",
        defaultAttr: {
          label: "付款人账号",
          placeholder: "请输入付款人账号",
        },
      },
      {
        type: "input",
        prop: "payeeActno",
        defaultAttr: {
          label: "收款人账号",
          placeholder: "请输入收款人账号",
        },
      },
      {
        type: "dict",
        dict: "TXN_SOURCE",
        prop: "source",
        defaultAttr: {
          label: "来源",
          placeholder: "请选择来源",
        },
      },
    ];
  },
  methods: {
    beforeSearchCallback() {
      console.log("搜索按钮之前先执行")
      // 搜索按钮之前先执行
      this.queryParams.amount1 = this.$refs.amountRangeSearch.getAmount1();
      this.queryParams.amount2 = this.$refs.amountRangeSearch.getAmount2();
    },
    clearCallBack() {
      let that = this;
      return new Promise(function (resolve, reject) {
        that.$refs.amountRangeSearch.clearAmount();
        that.queryParams.amount1 = "";
        that.queryParams.amount2 = "";
      });
    },
    editComplete(state) {
      console.log("editComplete", state);
      if (state == true) {
        this.getList();
      }
    },
    /** todo 查询当天操作员的交易记录 */
    getList() {
      this.doQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    transAdd() {
      console.log("this.$refs.editInfoDialog", this.$refs.editInfoDialog);
      this.$refs.editInfoDialog.show();
    },
    /*查看明细*/
    toViewDetail(row) {
      console.log("this.$refs.queryDetail", this.$refs);
      const queryDetails = {
        'hvps.111.001.01': 'queryDetail111',
        'hvps.115.001.01': 'queryDetail115',
        'hvps.112.001.01': 'queryDetail112',
        'hvps.116.001.01': 'queryDetail116',
        'hvps.117.001.01': 'queryDetail117',
        'hvps.118.001.01': 'queryDetail118',
        'beps.121.001.01': 'queryDetail121',
        'beps.122.001.01': 'queryDetail122',
        'beps.127.001.01': 'queryDetail127',
        'beps.127.001.02': 'queryDetail127',
        'beps.133.001.01': 'queryDetail133',
        'beps.125.001.01': 'queryDetail125',
        'hvps.141.001.01': 'queryDetail141001',
        'hvps.141.002.01': 'queryDetail141002',
      };
      if (queryDetails[row.pkgNo]) {
        const queryDetail = this.$refs[queryDetails[row.pkgNo]];
        queryDetail.show(row.coreId, row.pkgNo);
      }
    },

  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
